{
  "properties" : { },
  "id" : "23d7c84a7831450d9106f7ef12c6d655",
  "script" : null,
  "groupId" : "74af8e1135d2474eb9b6b4081e6d5967",
  "name" : "查询未绑定的设备",
  "createTime" : 1727071045518,
  "updateTime" : 1726653324485,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "pageForDevice",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n    \"current\": 1,\r\n    \"groupId\": \"26e88f64-18e0-4b00-8419-6c4aa3e86407\",\r\n    \"size\": 15\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": [\n        {\n            \"id\": \"D2173343257502001764\",\n            \"deviceName\": \"SN2.R1\",\n            \"ip\": \"2.61.0.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"1\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1814237884760947677\",\n            \"deviceName\": \"SN2.BD.R1\",\n            \"ip\": \"2.61.0.2\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"2\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1785952813461483572\",\n            \"deviceName\": \"SN2.R2\",\n            \"ip\": \"2.61.0.3\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"3\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D8175646130052275188\",\n            \"deviceName\": \"SN2-XA.R1\",\n            \"ip\": \"2.61.11.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"4\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D5712702224277450498\",\n            \"deviceName\": \"SN2-TC.R1\",\n            \"ip\": \"2.61.12.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"5\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D8396117811237249314\",\n            \"deviceName\": \"SN2-BJ.R1\",\n            \"ip\": \"2.61.13.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"6\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D7175563092666679777\",\n            \"deviceName\": \"SN2-XY.R1\",\n            \"ip\": \"2.61.14.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"7\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D3626777944021657299\",\n            \"deviceName\": \"SN2-WN.R1\",\n            \"ip\": \"2.61.15.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"8\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D4213284220006664719\",\n            \"deviceName\": \"SN2-HZ.R1\",\n            \"ip\": \"2.61.17.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"9\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1769297024146086962\",\n            \"deviceName\": \"SN2-YL.R1\",\n            \"ip\": \"2.61.18.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"10\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1919858423792924342\",\n            \"deviceName\": \"SN2.AK.R1\",\n            \"ip\": \"2.61.19.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"11\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1862224474573476513\",\n            \"deviceName\": \"SN2-SL.R1\",\n            \"ip\": \"2.61.20.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"12\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1643816517374081464\",\n            \"deviceName\": \"SN2.XX.R1\",\n            \"ip\": \"2.61.21.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干二平面\",\n            \"rowId\": \"13\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1643816517374081464\",\n            \"deviceName\": \"SN2.XX.R1\",\n            \"ip\": \"2.61.21.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"14\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D2964600861434994050\",\n            \"deviceName\": \"SN1.R1\",\n            \"ip\": \"4.61.0.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"15\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1183919004167388226\",\n            \"deviceName\": \"SN1.BD.R1\",\n            \"ip\": \"4.61.0.2\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"16\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1243852758798873183\",\n            \"deviceName\": \"SN1.R2\",\n            \"ip\": \"4.61.0.3\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"17\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1243852758798873183\",\n            \"deviceName\": \"SN1.R2\",\n            \"ip\": \"4.61.0.3\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"朔方变接入\",\n            \"rowId\": \"18\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D4754021083638062915\",\n            \"deviceName\": \"SN1-XA.R1\",\n            \"ip\": \"4.61.11.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"19\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D6678189305858383381\",\n            \"deviceName\": \"SN1-TC.R1\",\n            \"ip\": \"4.61.12.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"20\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D8393797155188268003\",\n            \"deviceName\": \"SN1-BJ.R1\",\n            \"ip\": \"4.61.13.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"21\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D7086705968830081535\",\n            \"deviceName\": \"SN1-XY.R1\",\n            \"ip\": \"4.61.14.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"22\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1197051607872627008\",\n            \"deviceName\": \"SN1-WN.R1\",\n            \"ip\": \"4.61.15.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"23\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1220589963321315315\",\n            \"deviceName\": \"SN1-HZ.R1\",\n            \"ip\": \"4.61.17.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"24\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1657982931920348755\",\n            \"deviceName\": \"SN1-YL.R1\",\n            \"ip\": \"4.61.18.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"\",\n            \"rowId\": \"25\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D2967075068513268780\",\n            \"deviceName\": \"SN1.AK.R1\",\n            \"ip\": \"4.61.19.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"26\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D1293543178517418683\",\n            \"deviceName\": \"SN1-SL.R1\",\n            \"ip\": \"4.61.20.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"27\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D4311751661874075545\",\n            \"deviceName\": \"SN1.XX.R1\",\n            \"ip\": \"4.61.21.1\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"1\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"骨干一平面\",\n            \"rowId\": \"28\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"骨干\"\n        },\n        {\n            \"id\": \"D2727910985461950695\",\n            \"deviceName\": \"NanJiaoB_XA_R\",\n            \"ip\": \"10.61.110.2\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"4\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"陕西省调\",\n            \"rowId\": \"29\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"接入\"\n        },\n        {\n            \"id\": \"D4472496089883807120\",\n            \"deviceName\": \"XinShengB_XA_R\",\n            \"ip\": \"10.61.110.4\",\n            \"deptName\": \"陕西省调\",\n            \"stationProp\": \"4\",\n            \"deviceType\": \"1\",\n            \"groupName\": \"陕西省调\",\n            \"rowId\": \"30\",\n            \"deviceTypeName\": \"路由器\",\n            \"stationValue\": \"接入\"\n        }\n    ]\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
 import org.springblade.common.cache.DictCache
 import java.util.function.Function
 import java.util.stream.Collectors
 import org.springframework.util.CollectionUtils


 var page = db.page("""
   SELECT
            d.id,
            d.device_name,
            d.ip,
            dept.dept_name,
            d.station_prop,
            d.device_type,
            g.group_name
        FROM
        ndmp_device d
        LEFT JOIN ndmp_group_device_relation dr ON dr.device_id = d.id
        LEFT JOIN ndmp_group g ON g.id = dr.group_id
        LEFT JOIN blade_dept dept ON dept.id = d.dcc_id
            where   d.mtnc_Status=0 and d.id  not in (select device_id from ndmp_group_device_relation where group_id=#{body.groupId})
        <if test="body.deviceName!=null and body.deviceName!=''">
            AND d.DEVICE_NAME like concat('%',#{body.deviceName},'%')
        </if>

        <if test="body.ip!=null and body.ip!=''">
            AND d.ip like concat('%',#{body.ip},'%')
        </if>

        <if test="body.deptId!=null and body.deptId!=''">
            AND dept.ID =#{body.deptId}
        </if>
        <if test="body.stationProp!=null and body.stationProp!=''">
            AND d.station_prop =#{body.stationProp}
        </if>

        order by inet_aton(ip)
  """)



 List res = page.get("records")
 if (CollectionUtils.isEmpty(res)) {
     return page
 }

 //  Map mergedMap = res.stream()
 //      .collect(Collectors.toMap(
 //          v -> v.get("id"), // 用于分组的 key
 //          Function.identity(), // 映射为 Device 对象
 //          (existing, replacement) -> { // 合并策略
 //              existing.put("groupName", (existing.get("groupName") + "," + replacement.get("groupName")));
 //              return existing;
 //          },
 //          HashMap::new // 创建一个新的 HashMap
 //      ));

 //  res = mergedMap.values().stream().collect(Collectors.toList());

 for (v in res) {
     v.put("deviceTypeName", DictCache.getValue("deviceType", v.get("deviceType")::int));
     v.put("stationValue", DictCache.getValue("stationProp", v.get("stationProp")::int));

 }
 page.put("records", res);
 return page